<?php
/**
 * @Author: rocky
 * @Copyright: 广州拓冠科技 <http://my8m.com>
 * Date: 2019/7/11
 * Time: 16:05
 */

namespace app\common\controller;

use app\api\service\WechatService;
use app\common\facade\Token;
use app\common\model\User;
use app\common\tools\ApiJson;


use think\Controller;

class BaseController extends Controller
{
    use ApiJson;
    protected $uid;
    protected $user;
    public function __construct()
    {
        parent::__construct();
        if(env('AUTH_DEBUG',false)){
            $user = User::find(env('AUTH_DEBUG_UID',null));
        }else{
            $user = WechatService::auth();
        }
        $this->user = $user;
        $this->uid = $user->id;
        $tokens = Token::encode($this->user);
        Token::set($tokens['token']);
    }
}